/*
day132
2020.1.7
*/
#include<vector>
#include<iostream>
#include<map> 
using namespace std;

class Solution1 {
public:
    vector<int> twoSum(vector<int>& nums, int target) 
	{
        map<int,int> m;
        vector<int> res;
        
        for(int i=0;i<nums.size();i++)
        {
        	if(m[target-nums[i] ] != 0)
        	{
        		res.push_back(m[target-nums[i] ]);
        		res.push_back(i);
        		return res;
			}
			
			else if(i!= 0 && nums[i] + nums[0] == target)
			{
				res.push_back(m[target-nums[i] ]);
        		res.push_back(i);
        		return res;
			}
			
			else
			{
				m[nums[i]] = i;
			}
		}
		
		return res;
    }
};


class Solution2 {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
		map<int ,int> m;
		vector<int> res;
		for(int i=0;i<nums.size();i++)
		{
			int tem=nums[i];
			if(m[target-tem] != 0)
			{
				res.push_back(m[target-tem]-1);
				res.push_back(i);
				return res;
			}
			
			else
			{
				m[tem] = i+1;
			}
		}
		
		return res;
    }
};

int main()
{
	return 0;
}
